var autodb = require('../db/auto.db')
var config = require('../config')
var emit = require('../emit')

function onsocket(socket,data){
    autodb.client(data.isMusic).scard(config.allfile,(err,response) => {
        var protocol = data.isMusic ? 'totalcount-music' : 'totalcount-sound';
        if(err){
            emit.send(socket,protocol, {count: 0});
        }else{
            emit.send(socket,protocol, {count: response});
        }
    })
}

module.exports = {
    onsocket
}